home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
comms
/
other
/
micq-0.4.0
/
util.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-05-14
|
26KB
|
823 lines
/*********************************************
**********************************************
This is a file of general utility functions useful
for programming in general and icq in specific
This software is provided AS IS to be used in
whatever way you see fit and is placed in the
public domain.
Author : Matthew Smith April 23, 1998
Contributors : airog (crabbkw@rose-hulman.edu) May 13, 1998
Changes :
6-18-98 Added support for saving auto reply messages. Fryslan
**********************************************
**********************************************/
#include "micq.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <time.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#ifdef _WIN32
#include <io.h>
#define S_IRUSR _S_IREAD
#define S_IWUSR _S_IWRITE
#endif
#ifdef UNIX
#include <unistd.h>
#include <termios.h>
#include "mreadline.h"
#endif
#ifdef __SASC
#include <proto/dos.h>
#include "amiga-dt.h"
#endif
#ifdef UNIX
char *strdup( const char * );
int strcasecmp( const char *, const char * );
int strncasecmp( const char *, const char *, size_t );
#endif
typedef struct
{
const char *name;
WORD code;
} COUNTRY_CODE;
static COUNTRY_CODE Country_Codes[] = { { USA_COUNTRY_STR, 1 },
{ Afghanistan_COUNTRY_STR, 93 },
{ Albania_COUNTRY_STR, 355 },
{ Algeria_COUNTRY_STR, 213 },
{ American_Samoa_COUNTRY_STR, 684 },
{ Andorra_COUNTRY_STR, 376 },
{ Angola_COUNTRY_STR, 244 },
{ Anguilla_COUNTRY_STR, 101 },
{ Antigua_COUNTRY_STR, 102 },
{ Argentina_COUNTRY_STR, 54 },
{ Armenia_COUNTRY_STR, 374 },
{ Aruba_COUNTRY_STR, 297 },
{ Ascention_Island_COUNTRY_STR, 274 },
{ Australia_COUNTRY_STR, 61 },
{ Australian_Antartic_Territory_COUNTRY_STR, 6721 },
{ Austria_COUNTRY_STR, 43 },
{ Azerbaijan_COUNTRY_STR, 934 },
{ Bahamas_COUNTRY_STR, 103 },
{ Bahrain_COUNTRY_STR, 973 },
{ Bangladesh_COUNTRY_STR, 880 },
{ Barbados_COUNTRY_STR, 104 },
{ Belarus_COUNTRY_STR, 375 },
{ Belgium_COUNTRY_STR, 32 },
{ Belize_COUNTRY_STR, 501 },
{ Benin_COUNTRY_STR, 229 },
{ Bermuda_COUNTRY_STR, 105 },
{ Bhutan_COUNTRY_STR, 975 },
{ Bolivia_COUNTRY_STR, 591 },
{ Bosnia_Herzegovina_COUNTRY_STR, 387 },
{ Botswana_COUNTRY_STR, 267 },
{ Brazil_COUNTRY_STR, 55 },
{ British_Virgin_Islands_COUNTRY_STR, 106 },
{ Brunei_COUNTRY_STR, 673 },
{ Bulgaria_COUNTRY_STR, 359 },
{ Burkina_Faso_COUNTRY_STR, 226 },
{ Burundi_COUNTRY_STR, 257 },
{ Cambodia_COUNTRY_STR, 855 },
{ Cameroon_COUNTRY_STR, 237 },
{ Canada_COUNTRY_STR, 107 },
{ Cape_Verde_Islands_COUNTRY_STR, 238 },
{ Cayman_Islands_COUNTRY_STR, 108},
{ Central_African_Republic_COUNTRY_STR, 236},
{ Chad_COUNTRY_STR, 235},
{ Christmas_Island_COUNTRY_STR, 672},
{ Cocos_Keeling_Islands_COUNTRY_STR, 6101},
{ Comoros_COUNTRY_STR, 2691},
{ Congo_COUNTRY_STR, 242},
{ Cook_Islands_COUNTRY_STR, 682},
{ Chile_COUNTRY_STR, 56 },
{ China_COUNTRY_STR, 86 },
{ Columbia_COUNTRY_STR, 57 },
{ Costa_Rice_COUNTRY_STR, 506 },
{ Croatia_COUNTRY_STR, 385 }, /* Observerd */
{ Cuba_COUNTRY_STR, 53 },
{ Cyprus_COUNTRY_STR, 357 },
{ Czech_Republic_COUNTRY_STR, 42 },
{ Denmark_COUNTRY_STR, 45 },
{ Diego_Garcia_COUNTRY_STR, 246},
{ Djibouti_COUNTRY_STR, 253},
{ Dominica_COUNTRY_STR, 109},
{ Dominican_Republic_COUNTRY_STR, 110},
{ Ecuador_COUNTRY_STR, 593 },
{ Egypt_COUNTRY_STR, 20 },
{ El_Salvador_COUNTRY_STR, 503 },
{ Equitorial_Guinea_COUNTRY_STR, 240},
{ Eritrea_COUNTRY_STR, 291},
{ Estonia_COUNTRY_STR, 372},
{ Ethiopia_COUNTRY_STR, 251 },
{ Former_Yugoslavia_COUNTRY_STR, 389},
{ Faeroe_Islands_COUNTRY_STR, 298},
{ Falkland_Islands_COUNTRY_STR, 500},
{ Federated_States_of_Micronesia_COUNTRY_STR, 691 },
{ Fiji_COUNTRY_STR, 679 },
{ Finland_COUNTRY_STR, 358 },
{ France_COUNTRY_STR, 33 },
{ French_Antilles_COUNTRY_STR, 596 }, /* Leave it */
{ French_Antilles_COUNTRY_STR, 5901 }, /* Either on or the other is right :) */
{ French_Guiana_COUNTRY_STR, 594 },
{ French_Polynesia_COUNTRY_STR, 689 },
{ Gabon_COUNTRY_STR, 241 },
{ Gambia_COUNTRY_STR, 220 },
{ Georgia_COUNTRY_STR, 995 },
{ Germany_COUNTRY_STR, 49 },
{ Ghana_COUNTRY_STR, 233 },
{ Gibraltar_COUNTRY_STR, 350 },
{ Greece_COUNTRY_STR, 30 },
{ Greenland_COUNTRY_STR, 299 },
{ Grenada_COUNTRY_STR, 111 },
{ Guadeloupe_COUNTRY_STR, 590 },
{ Guam_COUNTRY_STR, 671 },
{ Guantanomo_Bay_COUNTRY_STR, 5399 },
{ Guatemala_COUNTRY_STR, 502 },
{ Guinea_COUNTRY_STR, 224 },
{ Guinea_Bissau_COUNTRY_STR, 245 },
{ Guyana_COUNTRY_STR, 592 },
{ Haiti_COUNTRY_STR, 509 },
{ Honduras_COUNTRY_STR, 504 },
{ Hong_Kong_COUNTRY_STR, 852 },
{ Hungary_COUNTRY_STR, 36 },
{ Iceland_COUNTRY_STR, 354 },
{ India_COUNTRY_STR, 91 },
{ Indonesia_COUNTRY_STR, 62 },
{ INMARSAT_COUNTRY_STR, 870 },